package com.zuihai.app.mvp.model.entity;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.tencent.mm.opensdk.modelpay.PayReq;

/**
 * Created by Administrator on 2017/6/10 0010.
 */

public class WXPayResponse {
    private final static int SUCCESS = 0000;

    @SerializedName("code")
    @Expose
    public int code;
    @SerializedName("msg")
    @Expose
    public String msg;
    @SerializedName("data")
    @Expose
    public WeChatPay data;

    public boolean isSuccess(){
        return code == SUCCESS;
    }

    @Override
    public String toString() {
        return "WXPayResponse{" +
                "code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                ", data='" + data + '\'' +
                '}';
    }

    public static class WeChatPay{
        @SerializedName("appid")
        @Expose
        public String appid;
        @SerializedName("noncestr")
        @Expose
        public String noncestr;
        @SerializedName("package")
        @Expose
        public String pkg;
        @SerializedName("partnerid")
        @Expose
        public String partnerid;
        @SerializedName("prepayid")
        @Expose
        public String prepayid;
        @SerializedName("sign")
        @Expose
        public String sign;
        @SerializedName("timestamp")
        @Expose
        public String timestamp;

        public PayReq clonPayReq(){
            PayReq payReq = new PayReq();
            payReq.appId = appid;
            payReq.partnerId = partnerid;
            payReq.prepayId= prepayid;
            payReq.packageValue = pkg;
            payReq.nonceStr= noncestr;
            payReq.timeStamp= timestamp;
            payReq.sign= sign;
            payReq.checkArgs();
            return payReq;
        }

        @Override
        public String toString() {
            return "WeChatPay{" +
                    "appid='" + appid + '\'' +
                    ", noncestr='" + noncestr + '\'' +
                    ", pkg='" + pkg + '\'' +
                    ", partnerid='" + partnerid + '\'' +
                    ", prepayid='" + prepayid + '\'' +
                    ", sign='" + sign + '\'' +
                    ", timestamp='" + timestamp + '\'' +
                    '}';
        }
    }

}
